/*
 * @FilePath: \undefinedc:\Users\sxjct\.leetcode\153.寻找旋转排序数组中的最小值.cpp
 * @Brief: 
 * @Version: 1.0
 * @Date: 2021-04-08 19:50:31
 * @Author: tianyiyi
 * @Copyright: Copyright@tianyiyi
 * @LastEditors: Mr.Tian
 * @LastEditTime: 2021-04-08 20:56:18
 */
/*
 * @lc app=leetcode.cn id=153 lang=cpp
 *
 * [153] 寻找旋转排序数组中的最小值
 */

// @lc code=start
class Solution {
public:
    int findMin(vector<int>& nums) {
        int left = 0;
        int right = nums.size() - 1;
        while (left <= right)
        {
            int mid = (right - left)/2 + left;
            if(nums[mid] < nums[right])
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }

        }
        return nums[left];
        // while (left < right && nums[left] > nums[right])
        // {
        //     left++;
        // }
        // return nums[left];
        
    }
};
// @lc code=end

